<template>
  <div class="">
    <div class="sweets-wrapper">
      <div class="top-sweets">
      </div>
      <div class="block-wrapper">
        <block
          :productInfo="productInfo"
          @deleteProduct="deleteGoods"
          :deleteGoods="true"></block>
      </div>
    </div>
    <nav-footer></nav-footer>
  </div>
</template>

<script>
import navFooter from '../public/navFooter'
import block from '../components/block'
import axios from 'axios'
export default {
  components: {
    navFooter,
    block
  },
  data () {
    return {
      productInfo: []
    }
  },
  mounted () {
    this.getDetailInfo()
  },
  methods: {
    getDetailInfo () {
      axios.get('/goods/list').then((res) => {
        console.log(res)
        this.productInfo = res.data.result.list
      })
    },
    deleteGoods (productId) {
      axios.post('/goods/delete', {
        productId: productId
      }).then((response) => {
        console.log(response)
        this.getDetailInfo()
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.sweets-wrapper {
  margin-bottom: 30px;
  .top-sweets {
    padding-top: 40px;
    .top {
      width: 11%;
      height: 30px;
      display: flex;
      margin: 0 auto;
      margin-bottom: 10px;
      span {
        padding: 20px;
        padding-top: 8px;
        color: #8f6228;
      }
    }
    p {
      text-align: center;
      letter-spacing: 10px;
      color: #857560;
    }
    .sort {
      float: right;
      color: #fff;
      margin-right: 50px;
      padding: 10px;
      background-color: #fab965;
      border: 1px solid #fdef27;
      cursor: pointer;
      border-radius: 8px;
    }
  }
  .checked-li {
    width: 40%;
    margin: 40px auto;
    display: flex;
    li {
      padding: 10px 35px 10px 30px;
      background-color: #bf803e;
      flex-direction: row;
      justify-content: space-between;
      text-align: center;
      color: #fff;
    }
    li:hover {
      background-color: #ac6e2e;
      font-weight: 700;
    }
    .cur {
      background-color: #ac6e2e;
      font-weight: 700;
    }
  }
  .block-wrapper {
    width: 70%;
    margin-left: 300px;
  }
}
</style>
